package com.jili.blog.dao.controller;

import com.jili.blog.service.ArticleService;
import com.jili.blog.vo.Result;
import com.jili.blog.vo.params.PageParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("articles")
@Slf4j
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    /**
     * 首页文章列表
     * @param params
     * @return
     */
    @PostMapping
    public Result listArticle(@RequestBody PageParams params){

        return articleService.listArticle(params);
    }

    /**
     * 首页最热文章
     * @return
     */

    @PostMapping("hot")
    public Result hotArticle(){
        int limit=5;
        return articleService.hotArticle(limit);
    }

    /**
     * 首页最新文章
     * @return
     */

    @PostMapping("new")
    public Result newArticle(){
        int limit=5;
        return articleService.newArticle(limit);
    }

    /**
     * 文章归档
     * @return
     */
    @PostMapping("listArchives")
    public Result listArchives(){
        return articleService.listArchives();
    }
}
